from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModDepWorkloadRep import DepWorkloadRep, depWorkloadRepSchema
from database import Session, engine
import datetime
from dao import DaoRepeatProRep
from dao import DaoWorkRecord


class RepeatProRep(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
           begin_time = request.query_params["begintime"]
           end_time = request.query_params["endtime"]
           openid = request.query_params["openid"]
           return  DaoRepeatProRep.get_Repeat_Pro_Rep(session, begin_time, end_time, openid)
        finally:
            session.close()

class RepeatProRepDetail(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
           begin_time = request.query_params["begintime"]
           end_time = request.query_params["endtime"]
           bureauid = request.query_params["bureauid"]
           return DaoWorkRecord.get_repeat_pro_detail(session, begin_time, end_time, bureauid)
        finally:
            session.close()
